package beans;

import java.io.IOException;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

import daos.ExamenDAO;
import daosimp.ExamenDAOIMP;
import modelo.Alumno;
import modelo.Examen;
import modelo.Matricula;

@ManagedBean
@RequestScoped
public class CPGAlumnoBean {

	private Alumno alumno;
	private Matricula matricula;

	public boolean verificarSesion() {
		boolean estado = false;
		alumno = (Alumno) FacesContext.getCurrentInstance()
				.getExternalContext().getSessionMap().get("alumno");
		if (alumno != null) {
			setMatricula((Matricula) FacesContext.getCurrentInstance()
					.getExternalContext().getSessionMap().get("matriculaSelec"));
			estado = true;
		}
		return estado;
	}

	public void rendirExamen() {
		try {
			FacesContext.getCurrentInstance().getExternalContext()
					.redirect("pantallaExamen.xhtml");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public Matricula getMatricula() {
		return matricula;
	}

	public void setMatricula(Matricula matricula) {
		this.matricula = matricula;
	}

	public Alumno getAlumno() {
		return alumno;
	}

	public void setAlumno(Alumno alumno) {
		this.alumno = alumno;
	}

}
